package com.miage.kangourou.client.beans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.bradrydzewski.gwt.calendar.client.Appointment;
import com.bradrydzewski.gwt.calendar.client.AppointmentStyle;

public class Evenement extends Appointment implements Serializable {

	private static final long serialVersionUID = -5783922006206227022L;

	public static AppointmentStyle stringToAppointmentStyle(String color) {

		AppointmentStyle toReturn = AppointmentStyle.DEFAULT;

		if (color.equalsIgnoreCase("BLUE")) {
			toReturn = AppointmentStyle.BLUE;
		}
		if (color.equalsIgnoreCase("RED")) {
			toReturn = AppointmentStyle.RED;
		}
		if (color.equalsIgnoreCase("PINK")) {
			toReturn = AppointmentStyle.PINK;
		}
		if (color.equalsIgnoreCase("PURPLE")) {
			toReturn = AppointmentStyle.PURPLE;
		}
		if (color.equalsIgnoreCase("LIGHT_BLUE")) {
			toReturn = AppointmentStyle.LIGHT_BLUE;
		}
		if (color.equalsIgnoreCase("YELLOW_GREEN")) {
			toReturn = AppointmentStyle.YELLOW_GREEN;
		}
		if (color.equalsIgnoreCase("ORANGE")) {
			toReturn = AppointmentStyle.ORANGE;
		}
		if (color.equalsIgnoreCase("LIGHT_PURPLE")) {
			toReturn = AppointmentStyle.LIGHT_PURPLE;
		}
		if (color.equalsIgnoreCase("GREY")) {
			toReturn = AppointmentStyle.GREY;
		}
		if (color.equalsIgnoreCase("BROWN")) {
			toReturn = AppointmentStyle.BROWN;
		}
		if (color.equalsIgnoreCase("TEAL")) {
			toReturn = AppointmentStyle.TEAL;
		}

		return toReturn;

	}

	private int id_salle;
	private int id_type;
	private int id_enseignant;
	private int id_matiere;
	private int id_groupe;
	private int id_ue;
	private int id_promo;
	private String commentaire;

	private int id_evenement_recurrence;

	private Date recurrence_debut;
	private Date recurrence_fin;
	private List<Integer> recurrence_jours;

	public Evenement() {

	}

	public Evenement(int id_evenement, int id_salle, int id_type,
			int id_enseignant, int id_matiere, int id_groupe,
			String commentaire, Date dateDebut, Date dateFin,
			int id_evenement_recurrence) {

		setId(String.valueOf(id_evenement));
		this.id_salle = id_salle;
		this.id_type = id_type;
		this.id_enseignant = id_enseignant;
		this.id_matiere = id_matiere;
		this.id_groupe = id_groupe;

		this.commentaire = commentaire;
		setStart(dateDebut);
		setEnd(dateFin);

		this.setId_evenement_recurrence(id_evenement_recurrence);

		this.setRecurrence_debut(dateDebut);
		this.setRecurrence_fin(dateFin);
		this.setRecurrence_jours(new ArrayList<Integer>());
	}

	public Evenement(int id_evenement, int id_salle, int id_type,
			int id_enseignant, int id_matiere, int id_groupe,
			String commentaire, Date dateDebut, Date dateFin,
			int id_evenement_recurrence, Date recurrence_debut,
			Date recurrence_fin, List<Integer> jours_repetition) {

		this(id_evenement, id_salle, id_type, id_enseignant, id_matiere,
				id_groupe, commentaire, dateDebut, dateFin,
				id_evenement_recurrence);

		this.recurrence_debut = recurrence_debut;
		this.recurrence_fin = recurrence_fin;
		recurrence_jours = jours_repetition;
	}

	public void configureAppointment(String enseignant, String matiere,
			String groupe, String salle, String color) {

		setStyle(stringToAppointmentStyle(color));
		setTitle(matiere);
		setDescription(enseignant + "<br />" + groupe + "<br />" + salle
				+ "<br />");

	}

	public String getCommentaire() {
		return commentaire;
	}

	public int getId_enseignant() {
		return id_enseignant;
	}

	public int getId_evenement_recurrence() {
		return id_evenement_recurrence;
	}

	public int getId_groupe() {
		return id_groupe;
	}

	public int getId_matiere() {
		return id_matiere;
	}

	public int getId_promo() {
		return id_promo;
	}

	public int getId_salle() {
		return id_salle;
	}

	public int getId_type() {
		return id_type;
	}

	public int getId_ue() {
		return id_ue;
	}

	public Date getRecurrence_debut() {
		return recurrence_debut;
	}

	public Date getRecurrence_fin() {
		return recurrence_fin;
	}

	public List<Integer> getRecurrence_jours() {
		return recurrence_jours;
	}

	public boolean isEventRecurrent() {
		return (getId_evenement_recurrence() != 0);
	}

	public void setCommentaire(String commentaire) {
		this.commentaire = commentaire;
	}

	public void setId_enseignant(int id_enseignant) {
		this.id_enseignant = id_enseignant;
	}

	public void setId_evenement_recurrence(int id_evenement_recurrence) {
		this.id_evenement_recurrence = id_evenement_recurrence;
	}

	public void setId_groupe(int id_groupe) {
		this.id_groupe = id_groupe;
	}

	public void setId_matiere(int id_matiere) {
		this.id_matiere = id_matiere;
	}

	public void setId_promo(int id_promo) {
		this.id_promo = id_promo;
	}

	public void setId_salle(int id_salle) {
		this.id_salle = id_salle;
	}

	public void setId_type(int id_type) {
		this.id_type = id_type;
	}

	public void setId_ue(int id_ue) {
		this.id_ue = id_ue;
	}

	public void setRecurrence_debut(Date recurrenceDebut) {
		recurrence_debut = recurrenceDebut;
	}

	public void setRecurrence_fin(Date recurrenceFin) {
		recurrence_fin = recurrenceFin;
	}

	public void setRecurrence_jours(List<Integer> recurrenceJours) {
		recurrence_jours = recurrenceJours;
	}

}
